<style scoped>
.clientSalesQuery {
  margin-right: 0.5vw;
  padding: 0 15px;
  background-color: white;
  height: 95vh;
  position: relative;
}
.csq_top {
  padding-top: 1vh;
  white-space: nowrap;
}
.csq_top p:first-child {
  margin: 3px 6px 0 0;
  display: inline-block;
}
.csq_top p:not(:first-child) {
  margin: 3px 6px 0 12px;
  display: inline-block;
}
.csq_inp {
  width: 3vw;
  margin-right: 0.5vw;
}
.csq_select {
  width: 8vw;
}
.csq_inp1 {
  width: 8vw;
}
.csq_top1 {
  display: flex;
  padding: 0 0 15px 0;
  justify-content: space-between;
  white-space: nowrap;
}
.csq_top1 > div:first-child > p {
  margin: 3px 6px 0 0;
}
.csq_top1 div {
  display: flex;
}
.csq_button {
  padding: 1vh 0;
  white-space: nowrap;
}
.csq_button div {
  display: inline-block;
}
.csq_tab {
  display: flex;
  height: 75%;
  width: 100%;
}
#content1 {
  width: 30%;
}
#content2 {
  width: 69%;
}
.divider {
  width: 1%;
  height: 98%;
  background-color: #f4f4f4;
  cursor: pointer;
}
.divider i {
  position: absolute;
  top: 50%;
  font-weight: 1000;
  color: #017aff;
}
.footView span {
  float: left;
  margin-right: 48px;
  line-height: 6vh;
  font-size: 14px;
}
.footView span i {
  margin-right: 5px;
}

.print {
  width: 260px;
  height: 120px;
  background: white;
  position: absolute;
  top: 26%;
  left: 37%;
  z-index: 2;
  padding: 10px 15px;
  box-shadow: 3px 3px 3px #f4f4f4;
}
.print div:first-child {
  font-weight: 700;
  margin-bottom: 5px;
}
.print div:last-child {
  float: right;
  margin: 10px 0 0 0;
}

.clientSalesQuery #imgBox {
  position: absolute;
  max-width: 40vw;
  max-height: 40vh;
  z-index: 1;
}
.clientSalesQuery #imgBox .imgTop {
  background-color: #f4f4f4;
  height: 30px;
  padding-left: 10px;
}
.clientSalesQuery #imgBox .imgTop i {
  float: right;
  height: 30px;
  width: 30px;
  line-height: 30px;
}
.clientSalesQuery #imgBox img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.clientSalesQuery .exPort {
  width: 280px;
  height: 120px;
  background: white;
  position: absolute;
  top: 26%;
  left: 32%;
  z-index: 2;
  padding: 10px 15px;
  box-shadow: 3px 3px 3px #f4f4f4;
}
.clientSalesQuery .exPort div:first-child {
  font-weight: 700;
  margin-bottom: 5px;
}
.clientSalesQuery .exPort div:last-child {
  float: right;
  margin: 10px 0 0 0;
}
.tip {
  border: 1px;
  border-radius: 50%;
  width: 13px;
  height: 13px;
  margin: 6px 5px 0 5px;
}
.tip1 {
  border: 1px;
  border-radius: 50%;
  width: 13px;
  height: 13px;
  margin: 6px 1px 0 4px;
}
</style>

<style>
.clientSalesQuery .el-input__icon {
  line-height: 22px;
}
.clientSalesQuery .csq_top .el-date-editor.el-input__inner {
  width: 15vw;
}
.clientSalesQuery .csq_top .el-input__inner {
  height: 30px;
  padding: 0 5px;
}
.clientSalesQuery .csq_top1 .el-input__inner {
  height: 30px;
}
.clientSalesQuery .csq_top .el-date-editor .el-range__icon,
.clientSalesQuery .csq_top .el-date-editor .el-range-separator {
  line-height: 23px;
}
.clientSalesQuery .csq_top .el-date-editor .el-range-separator {
  width: 7%;
}

.clientSalesQuery .csq_button .el-checkbox.is-bordered {
  padding: 4px 5px 0 5px;
  height: 30px;
}
.clientSalesQuery .print .el-radio {
  margin-right: 19px;
}

.clientSalesQuery .el-cascader .el-input__inner {
  height: 30px !important;
}
.clientSalesQuery .el-cascader__tags .el-tag {
  max-width: 55%;
}

.clientSalesQuery .el-pagination .el-select .el-input .el-input__inner,
.clientSalesQuery .el-pagination .el-select .el-input {
  width: 90px;
}
.clientSalesQuery .el-pagination {
  float: right;
  margin-top: 5px;
}
.clientSalesQuery .el-input--mini .el-input__inner {
  height: 23px;
}

.clientSalesQuery .el-table__footer td {
  height: 26px;
}
.clientSalesQuery .el-table .cell {
  padding: 0 0 0 5px;
}

.clientSalesQuery
  .el-pagination--small
  .el-pagination__editor.el-input
  .el-input__inner {
  width: 40px;
}
</style>

<template>
  <div class="clientSalesQuery">
    <div style="border-bottom: 2px solid #f4f4f4; padding-bottom: 1vh">
      <div class="csq_top">
        <p>客户</p>
        <!-- <el-input class="csq_inp" v-model="customerNo" @blur="customerNoBlur" :disabled="jxAgent"></el-input> -->
        <el-select
          filterable
          class="csq_select"
          v-model="customerName"
          @change="
            (e) => {
              this.customerNo = e
            }
          "
          :disabled="jxAgent"
        >
          <el-option
            v-for="item in customerList"
            :key="item.value"
            :label="item.value + '  ' + item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>总店编号</p>
        <el-input
          class="csq_inp1"
          v-model="headOfficeNumber"
          clearable
        ></el-input>
        <p>客销序号</p>
        <el-input
          class="csq_inp1"
          v-model="inputSequence1"
          clearable
        ></el-input>
        <p>品名</p>
        <el-select class="csq_inp1" v-model="commodityName" clearable>
          <el-option
            v-for="item in commodityNameList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>季度</p>
        <el-select class="csq_inp1" v-model="quarter" clearable>
          <el-option
            v-for="item in quarterList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>地区</p>
        <el-select class="csq_inp1" v-model="area" clearable>
          <el-option
            v-for="item in areaList"
            :key="item.id"
            :label="item.name"
            :value="item.name"
          ></el-option>
        </el-select>
        <p style="margin-left: 43px">日期</p>
        <el-date-picker
          unlink-panels
          v-model="dateList"
          type="daterange"
          value-format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </div>
      <div class="csq_top">
        <p>货号</p>
        <el-input class="csq_inp1" v-model="kindsNumber"></el-input>
        <p>配货方式</p>
        <el-select class="csq_inp1" v-model="cooperateWay">
          <el-option
            v-for="item in cooperateWayList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>单据确认</p>
        <el-select class="csq_inp1" v-model="affirm">
          <el-option
            v-for="item in affirmList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>品牌</p>
        <el-select class="csq_inp1" v-model="brandedName" clearable>
          <el-option
            v-for="item in brandList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>业务</p>
        <el-select class="csq_inp1" v-model="business" clearable>
          <el-option
            v-for="item in businessList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
        <p>单号</p>
        <el-input
          class="csq_inp1"
          v-model="receiptsNumber"
          clearable
        ></el-input>
      </div>
    </div>
    <div class="csq_button">
      <div>
        <el-button @click="search(1)" icon="el-icon-search" type="primary"
          >查询</el-button
        >
        <el-button
          @click="confirm"
          icon="el-icon-circle-check"
          :disabled="isConfirm"
          >确认</el-button
        >
        <el-button @click="audit" icon="el-icon-coordinate" :disabled="isAudit"
          >审核</el-button
        >
        <el-button
          @click="umpire"
          icon="el-icon-coordinate"
          :disabled="!isAudit"
          >反审</el-button
        >
        <el-button
          @click="supplement"
          icon="el-icon-document-add"
          :disabled="jxChangeOrder"
          >补单</el-button
        >
        <el-button
          @click="revision"
          icon="el-icon-edit-outline"
          :disabled="jxChangeOrder"
          >改单</el-button
        >
        <el-button @click="screenStyleNumber" icon="el-icon-copy-document"
          >筛选款号</el-button
        >
        <!-- <el-button icon="el-icon-wallet">售价异常</el-button> -->
        <el-button @click="Export" icon="el-icon-upload2">导出</el-button>
        <el-button @click="printConfirm" icon="el-icon-printer">列印</el-button>
        <el-button @click="dele" icon="el-icon-delete" :disabled="jxChangeOrder"
          >删除</el-button
        >
      </div>
      <div style="float: right; display: flex">
        <div style="margin-top: 5px; display: flex; padding-right: 10px">
          <div class="tip" style="background: #6bcc7b"></div>
          :已完成
          <div class="tip" style="background: #ff0000"></div>
          :未确认
          <div class="tip" style="background: rgb(101, 49, 142)"></div>
          :未结账
        </div>
        <el-checkbox
          style="margin: 0 10px 0 0"
          v-model="dailySettlement"
          border
          :disabled="twoDimensional || adjustPrice"
          >日结</el-checkbox
        >
        <el-checkbox
          style="margin: 0"
          v-model="adjustPrice"
          border
          :disabled="twoDimensional || dailySettlement"
          >查询调整过售价</el-checkbox
        >
        <el-checkbox
          style="margin: 0 0 0 10px"
          v-model="twoDimensional"
          border
          :disabled="adjustPrice || dailySettlement"
          >二维</el-checkbox
        >
      </div>
    </div>
    <div class="csq_tab">
      <div id="content1">
        <!-- 这里是点击确认的时候，应该要修改的参数 -->
        <el-table
          ref="table1"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '30px'
          }"
          :cell-style="changeCellStyle"
          :data="sequenceData"
          border
          height="70vh"
          style="width: 100%"
          highlight-current-row
          @row-click="rowClick"
        >
          <el-table-column
            type="index"
            label="序号"
            width="50"
          ></el-table-column>
          <el-table-column label="单据状态" width="80">
            <template slot-scope="scope">
              <div style="display: flex; text-align: center">
                <!-- 0是未确认，4是未结账，其他都是已完成 -->
                <div
                  class="tip1"
                  :style="{
                    background:
                      scope.row.sequenceStatus == 0
                        ? '#FF0000'
                        : scope.row.sequenceStatus == 4
                        ? 'rgb(101, 49, 142)'
                        : '#6BCC7B'
                  }"
                ></div>
                <p>
                  {{
                    scope.row.sequenceStatus == 0
                      ? '未确认'
                      : scope.row.sequenceStatus == 4
                      ? '未结账'
                      : '已完成'
                  }}
                </p>
              </div>
            </template>
          </el-table-column>
          <el-table-column
            prop="sellSequence"
            label="客销序号"
            width="120"
            v-if="!dailySettlement"
          ></el-table-column>
          <el-table-column
            prop="vipSellSequence"
            label="店销序号"
            width="120"
            v-if="!dailySettlement"
          ></el-table-column>
          <el-table-column
            prop="sellTime"
            label="销货日期"
            min-width="100"
          ></el-table-column>
          <el-table-column
            prop="customerStr"
            label="客户"
            min-width="120"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="number"
            label="数量"
            min-width="60"
          ></el-table-column>
          <el-table-column
            prop="tagPrice"
            label="吊牌金额"
            width="100"
            v-if="!dailySettlement"
          ></el-table-column>
          <el-table-column
            prop="discount"
            label="折数"
            width="50"
            v-if="!dailySettlement"
          ></el-table-column>
          <el-table-column
            prop="money"
            label="金额"
            min-width="100"
          ></el-table-column>
          <el-table-column
            prop="operator"
            label="操作员"
            width="100"
            v-if="!dailySettlement"
            show-overflow-tooltip
          ></el-table-column>
          <!-- <el-table-column prop="affirm" label="确认" width="50" v-if="!dailySettlement"></el-table-column> -->
          <el-table-column
            prop="checks"
            label="审核"
            width="50"
            v-if="!dailySettlement"
          ></el-table-column>
          <el-table-column
            prop="remark"
            label="备注"
            width="200"
            v-if="!dailySettlement"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            prop="enteringTime"
            label="录入时间"
            width="160"
            v-if="!dailySettlement"
          ></el-table-column>
        </el-table>
        <el-pagination
          small
          background
          ref="paginationLeft"
          layout="prev, pager, next, jumper, sizes"
          :page-sizes="[20, 50, 100, 200]"
          :page-size="limitLeft"
          :page-count="pagesNumLeft"
          :total="dataLenLeft"
          @current-change="handleCurrentChangeLeft"
          @size-change="handleSizeChangeLeft"
        ></el-pagination>
      </div>
      <div class="divider" @click="dividerClick">
        <i v-if="!areaFlag" class="el-icon-arrow-right"></i>
        <i v-if="areaFlag" class="el-icon-arrow-left"></i>
      </div>
      <div id="content2">
        <el-table
          id="outTable"
          ref="table2"
          :data="kindsNumberData"
          height="70vh"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '30px'
          }"
          :cell-style="{ padding: 0, height: '26px' }"
          style="width: 100%"
          highlight-current-row
          show-summary
          border
          :summary-method="getSummaries"
          @row-click="detailClick"
        >
          <el-table-column
            type="index"
            label="序号"
            width="50"
          ></el-table-column>
          <template v-for="i in knhList">
            <el-table-column
              :prop="i.prop"
              :label="i.label"
              :width="i.width"
              :key="i.prop"
              v-if="i.isShow"
              show-overflow-tooltip
            ></el-table-column>
          </template>
          <el-table-column
            prop="image"
            label="图片"
            v-if="twoDimensional"
            width="80"
          >
            <template slot-scope="scope">
              <p
                @click="checkImg(scope.row)"
                style="color: #017aff; cursor: pointer"
              >
                查看大图
              </p></template
            >
          </el-table-column>
        </el-table>
        <el-pagination
          small
          background
          ref="paginationRight"
          layout="prev, pager, next, jumper, sizes"
          :page-sizes="[20, 50, 100, 200]"
          :page-size="limit"
          :page-count="pagesNum"
          :total="dataLen"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        ></el-pagination>
      </div>
    </div>
    <!-- 导出 -->
    <div class="exPort" v-show="showExport">
      <div>导出方式</div>
      <el-radio v-model="exportType" label="1">导出汇总表</el-radio>
      <el-radio v-model="exportType" label="2">导出右表</el-radio>
      <!-- <el-radio v-model="exportType" label="2">导出客户进货明细</el-radio> -->
      <div>
        <el-button
          @click="
            () => {
              this.showExport = false
            }
          "
          >取消</el-button
        >
        <el-button @click="exportConfirm" type="primary">确定</el-button>
      </div>
    </div>
    <!-- 改单密码验证 -->
    <verify-password
      v-if="showpwd"
      :operationType="operationType"
      :isConfirm="isConfirm"
      @closepwd="
        () => {
          this.showpwd = false
        }
      "
      @showRevision="showRevision"
    ></verify-password>
    <!-- 改单 -->
    <srevi-sion
      v-show="showCReviSion"
      :Str="this.Str"
      :flag="showCReviSion"
      :customerL="customerList"
      :selectInputSequence="inputSequence"
      :detailRow="detailRow"
      @closeReviSion="
        () => {
          this.showCReviSion = false
        }
      "
      @modifySuc="search"
    ></srevi-sion>
    <!-- 补单输入框 -->
    <sup-order
      v-show="showSupOrder"
      :sequence="inputSequence"
      @closeuopplement="
        () => {
          this.showSupOrder = false
        }
      "
      @determine="determine"
    ></sup-order>
    <!-- 筛选款号 -->
    <screen-type
      v-show="showScreen"
      @closeScreenType="
        () => {
          this.showScreen = false
        }
      "
      @changeConditions="changeConditions"
    ></screen-type>
    <!-- 查看图片 -->
    <div id="imgBox" v-show="showImg" ref="imgBoxDom">
      <div class="imgTop">
        <span style="line-height: 30px; font-weight: bold">显示图片</span>
        <i
          class="el-icon-close"
          @click="
            () => {
              this.showImg = false
            }
          "
        ></i>
      </div>
      <div class="img">
        <img :src="imgSrc" ondragstart="return false;" />
      </div>
    </div>
    <!-- 底部框 -->
    <foot-view class="footView">
      <div slot="text">
        <el-popover
          placement="top-start"
          width="120"
          max-height="100px"
          trigger="click"
        >
          <el-checkbox-group v-model="selectHeaderList">
            <el-checkbox
              v-for="i in headerList"
              :label="i.value"
              :key="i.value"
              style="margin-bottom: 7px"
            ></el-checkbox>
          </el-checkbox-group>
          <i slot="reference" class="el-icon-date">表头配置</i></el-popover
        >
        <span>数据库：{{ jxQuarter }}</span>
        <span>操作员：{{ operator }}</span>
        <span>记录数：{{ amount }}</span>
      </div>
    </foot-view>
    <print-area
      v-show="false"
      isInput="销"
      isVendor="客户"
      :manufacturerName="printVendorName"
      :principal="contact"
      :phone="phone"
      :address="address"
      :remark="printRemark"
      :inputSequence="inputSequence"
      :jxQuarter="jxQuarter"
      :inputDate="inputDate"
      :printTotal="printTotal"
      :printMoney="printMoney"
      :printStyle="printStyle"
      :printSellingPrice="printSellingPrice"
      :printType="printType"
      :shipType="shipType"
      :cellphone="cellphone"
      :companyName="companyName"
      :companyPhone="companyPhone"
    ></print-area>
  </div>
</template>

<script>
const resources = require('../../../config/printCSS')

import footView from '../../../components/FootView'
import verifyPassword from '../../../components/VerifyPassword'
import supOrder from '../../../components/SupOrder'
import sreviSion from './childComp/SReviSion'
import screenType from './childComp/screenType'
import printArea from '../../../components/PrintVendorStock'

import { getClient } from '../../../network/client'
import { getProductName } from '../../../network/productName'
import { getBranded } from '../../../network/branded'
import { getKindsNumberList } from '../../../network/artNo'
import {
  getSellInquire,
  daySellInfo,
  getAdjustmentSellingPrice,
  affirmSell,
  checkYse,
  checkNo,
  settleAccountsStatus
} from '../../../network/sellTotal'
import { getClerk } from '../../../network/clerk'
import { getSystemConfig } from '../../../network/operatoryCommand'
import { getQuarter } from '../../../network/quarter'

import today from '../../../components/mixins/today'
import enterUp from '../../../components/mixins/enterUp'
import cookieFn from '../../../components/mixins/cookieFn'

import table2excel from 'js-table2excel'
import XLSX from 'xlsx'
import FileSaver from 'file-saver'

import { provincea } from '../../../config/address'

import { newCloumn } from '../../../util/exportExcelTitle'

export default {
  name: 'client_sales_query',
  mixins: [today, enterUp, cookieFn],
  components: {
    footView,
    verifyPassword,
    supOrder,
    sreviSion,
    screenType,
    printArea
  },
  data() {
    return {
      Str: '',
      strRandom: Math.random().toString(36).substring(2, 7), //随机字符串
      inpList: [],
      // 总数据条数
      dataLenLeft: 0,
      // 总页码
      pagesNumLeft: 0,
      // 分页条数
      limitLeft: 20,
      // 当前页码
      currentPageLeft: 1,

      // 总数据条数
      dataLen: 0,
      // 总页码
      pagesNum: 0,
      // 分页条数
      limit: 20,
      // 当前页码
      currentPage: 1,

      props: { multiple: true },

      showImg: false,

      // 按钮
      isConfirm: false,
      isAudit: false,

      dateList: null,
      inputDateList: null,
      customerNo: '',
      customerName: '',
      customerList: [],
      headOfficeNumber: '',
      inputSequence: '',
      // 查询条件的序号
      inputSequence1: '',
      commodityName: '',
      commodityNameList: [],
      quarter: [],
      quarterList: [],
      area: '',
      areaList: [],
      kindsNumber: '',
      kindsNumberL: [],
      brandedName: '',
      brandList: [],
      business: '',
      businessList: [],
      receiptsNumber: '',

      affirm: '全部',
      affirmList: [
        { value: '全部', label: '全部' },
        { value: '未确认', label: '未确认' },
        { value: '已完成', label: '已完成' }
      ],
      cooperateWay: '全部',
      cooperateWayList: [
        { value: '全部', label: '全部' },
        { value: '配货', label: '配货' },
        { value: '订货', label: '订货' },
        { value: '订断', label: '订断' },
        { value: '追断', label: '追断' }
      ],

      imgSrc: '',
      amount: 0,

      // 左表
      sequenceData: [],
      sequenceDataList: [],

      // 右表
      kindsNumberData: [],
      // 右总表
      kindsNumberList: [],
      // 按条件查询出来的右总表
      conditionList: [],
      // 右二维表
      styleNumberList: [],
      // 查询调整过售价表
      adjustPriceList: [],
      // 选中的表
      selectList: [],
      // 日结
      dailyMap: {},
      totalByDay: [],
      // 每单二维表
      detailTwo: [],

      dailySettlement: false,
      adjustPrice: false,
      twoDimensional: false,

      showExport: false,
      showpwd: false,
      showCReviSion: false,
      showSupOrder: false,
      showScreen: false,

      operationType: 0,

      printType: '1',
      exportType: '1',

      knhList: [],
      // 一维表头
      knhList1: [
        { prop: 'sequence', label: '客销序号', width: '120', isShow: true },
        { prop: 'business', label: '业务', width: '80', isShow: true },
        { prop: 'name', label: '客户', width: '80', isShow: true },
        { prop: 'kindsNumber', label: '货号', width: '160', isShow: true },
        { prop: 'styleNumber', label: '款号', width: '100', isShow: true },
        { prop: 'colorNo', label: '颜色编号', width: '80', isShow: true },
        { prop: 'colorName', label: '颜色名称', width: '80', isShow: true },
        { prop: 'size', label: '尺码', width: '50', isShow: true },
        { prop: 'commodityName', label: '品名', width: '160', isShow: true },
        { prop: 'sellingPrice', label: '售价', width: '70', isShow: true },
        { prop: 'discount', label: '折数', width: '50', isShow: true },
        { prop: 'onePrice', label: '单价', width: '70', isShow: true },
        { prop: 'sum', label: '数量', width: '60', isShow: true },
        { prop: 'tagPrice', label: '吊牌金额', width: '70', isShow: true },
        { prop: 'money', label: '金额', width: '90', isShow: true },
        { prop: 'time', label: '客销日期', width: '100', isShow: true },
        { prop: 'remark', label: '备注', width: '200', isShow: true },
        { prop: 'brandedName', label: '品牌', width: '100', isShow: true },
        { prop: 'entryTime', label: '录入时间', width: '160', isShow: true }
      ],
      // 二维表头
      knhList2: [
        { prop: 'typeNumber', label: '款号', width: '120', isShow: true },
        { prop: 'sellingPrice', label: '售价', width: '100', isShow: true },
        { prop: 'colorName', label: '颜色', width: '100', isShow: true },
        { prop: 'c05', label: '05-XS', width: '100', isShow: true },
        { prop: 'c07', label: '07-S', width: '100', isShow: true },
        { prop: 'c09', label: '09-M', width: '100', isShow: true },
        { prop: 'c11', label: '11-L', width: '100', isShow: true },
        { prop: 'c13', label: '13-XL', width: '100', isShow: true },
        { prop: 'c15', label: '15-2L', width: '100', isShow: true },
        { prop: 'c17', label: '17-3L', width: '100', isShow: true },
        { prop: 'c19', label: '19-4L', width: '100', isShow: true },
        { prop: 'c21', label: '21-5L', width: '100', isShow: true },
        { prop: 'c23', label: '23-6L', width: '100', isShow: true },
        { prop: 'f', label: 'F', width: '80', isShow: true },
        { prop: 'total', label: '小计', width: '100', isShow: true },
        { prop: 'money', label: '金额', width: '100', isShow: true },
        { prop: 'tagPrice', label: '吊牌金额', width: '120', isShow: true }
      ],
      // 查询调整过售价
      knhList4: [
        { prop: 'sequence', label: '客销序号', width: '', isShow: true },
        { prop: 'no', label: '客户编号', width: '100', isShow: true },
        { prop: 'kindsNumber', label: '货号', width: '', isShow: true },
        { prop: 'sellingPrice', label: '售价', width: '120', isShow: true },
        {
          prop: 'fileSellingPrice',
          label: '建档售价',
          width: '120',
          isShow: true
        },
        { prop: 'sum', label: '数量', width: '100', isShow: true }
      ],

      detailRow: {},
      sequenceRow: {},

      operator: this.getCookie('jxUser'),
      jxQuarter: this.getCookie('jxQuarter'),
      jxAgent: this.getCookie('jxAgent') == '1',
      jxChangeOrder: this.getCookie('jxChangeOrder') == '0',
      jxShowCost: this.getCookie('jxShowCost') == '0',

      // 设置表头
      selectHeaderList: [
        '客销序号',
        '业务',
        '客户',
        '货号',
        '款号',
        '颜色编号',
        '颜色名称',
        '尺码',
        '品名',
        '售价',
        '折数',
        '单价',
        '数量',
        '吊牌金额',
        '金额',
        '厂价',
        '厂价金额',
        '利润',
        '客销日期',
        '备注',
        '品牌',
        '录入时间'
      ],
      headerList: [
        { value: '客销序号' },
        { value: '业务' },
        { value: '客户' },
        { value: '货号' },
        { value: '款号' },
        { value: '颜色编号' },
        { value: '颜色名称' },
        { value: '尺码' },
        { value: '品名' },
        { value: '售价' },
        { value: '折数' },
        { value: '单价' },
        { value: '数量' },
        { value: '吊牌金额' },
        { value: '金额' },
        { value: '厂价' },
        { value: '厂价金额' },
        { value: '利润' },
        { value: '客销日期' },
        { value: '备注' },
        { value: '品牌' },
        { value: '录入时间' }
      ],

      // 打印
      styleList: [],
      printTotal: 0,
      printMoney: 0,
      // 款号合计
      printStyle: 0,
      // 售价合计
      printSellingPrice: 0,
      // 客户
      printVendor: '',
      printVendorName: '',
      principal: '',
      contact: '',
      phone: '',
      cellphone: '',
      inputDate: '',
      address: '',
      shipType: '',
      printRemark: '',
      companyName: '',
      companyPhone: '',

      summation: {},
      areaFlag: false
    }
  },
  watch: {
    twoDimensional(a, b) {
      this.currentPage = 1
      this.$refs.paginationRight.internalCurrentPage = 1
      this.currentPageLeft = 1
      if (this.adjustPrice) this.adjustPrice = false
      if (this.dailySettlement) this.dailySettlement = false
      this.search(1)
      if (a) {
        // 显示二维表
        this.dataLen = this.styleNumberList.length
        this.knhList = this.knhList2
        this.kindsNumberData = this.styleNumberList.slice(0, this.limit)

        if (localStorage.getItem('jx_Ktitle2')) {
          this.selectHeaderList = localStorage.getItem('jx_Ktitle2').split(',')
        } else {
          this.selectHeaderList = [
            '款号',
            '颜色',
            '05-XS',
            '07-S',
            '09-M',
            '11-L',
            '13-XL',
            '15-2L',
            '17-3L',
            '19-4L',
            '21-5L',
            '23-6L',
            'F',
            '小计',
            '吊牌金额',
            '售价',
            '利润',
            '金额',
            '厂价',
            '厂价金额',
            '图片'
          ]
        }

        this.headerList = [
          { value: '款号' },
          { value: '颜色' },
          { value: '售价' },
          { value: '05-XS' },
          { value: '07-S' },
          { value: '09-M' },
          { value: '11-L' },
          { value: '13-XL' },
          { value: '15-2L' },
          { value: '17-3L' },
          { value: '19-4L' },
          { value: '21-5L' },
          { value: '23-6L' },
          { value: 'F' },
          { value: '小计' },
          { value: '吊牌金额' },
          { value: '金额' },
          { value: '厂价' },
          { value: '厂价金额' },
          { value: '利润' },
          { value: '图片' }
        ]
      } else {
        this.knhList = this.knhList1

        if (localStorage.getItem('jx_Ktitle1')) {
          this.selectHeaderList = localStorage.getItem('jx_Ktitle1').split(',')
        } else {
          this.selectHeaderList = [
            '客销序号',
            '业务',
            '客户',
            '货号',
            '款号',
            '颜色编号',
            '颜色名称',
            '尺码',
            '品名',
            '售价',
            '折数',
            '单价',
            '数量',
            '吊牌金额',
            '金额',
            '厂价',
            '厂价金额',
            '利润',
            '客销日期',
            '备注',
            '品牌',
            '录入时间'
          ]
        }

        this.headerList = [
          { value: '客销序号' },
          { value: '业务' },
          { value: '客户' },
          { value: '货号' },
          { value: '款号' },
          { value: '颜色编号' },
          { value: '颜色名称' },
          { value: '尺码' },
          { value: '品名' },
          { value: '售价' },
          { value: '折数' },
          { value: '单价' },
          { value: '数量' },
          { value: '吊牌金额' },
          { value: '金额' },
          { value: '厂价' },
          { value: '厂价金额' },
          { value: '利润' },
          { value: '客销日期' },
          { value: '备注' },
          { value: '品牌' },
          { value: '录入时间' }
        ]
        if (this.inputSequence) {
          this.dataLen = this.selectList.length
          this.kindsNumberData = this.selectList.slice(0, this.limit)
        } else {
          this.dataLen = this.kindsNumberList.length
          this.kindsNumberData = this.conditionList.slice(0, this.limit)
        }
      }
    },
    adjustPrice(a, b) {
      this.currentPage = 1
      this.currentPageLeft = 1
      this.$refs.paginationRight.internalCurrentPage = 1
      this.$refs.paginationLeft.internalCurrentPage = 1
      this.dataLen = 0
      this.dataLenLeft = 0
      this.sequenceData = []
      this.kindsNumberData = []
      this.kindsNumberList = []
      this.styleNumberList = []
      if (a) {
        getAdjustmentSellingPrice().then((res) => {
          this.knhList = this.knhList4
          this.adjustPriceList = res.data.data
          this.dataLen = this.adjustPriceList.length

          this.summation.sum = 0
          this.summation.money = 0
          this.adjustPriceList.forEach((e) => {
            this.summation.sum += Number(e.sum)
            this.summation.money += Number(e.money)
          })
          this.kindsNumberData = this.adjustPriceList.slice(0, this.limit)
        })
      } else {
        this.knhList = this.knhList1
        this.search()
      }
    },
    dailySettlement(a, b) {
      if (a) {
        this.twoDimensional = false
        this.adjustPrice = false
        this.currentPageLeft = 1
        this.$refs.paginationLeft.internalCurrentPage = 1
        this.getDaySellInfo()
      } else {
        this.search(1)
      }
    },
    selectHeaderList(a, b) {
      let tmpList = []
      let tmpList2 = []
      let tmpList4 = []
      this.headerList.forEach((e) => {
        if (a.indexOf(e.value) == -1) {
          tmpList = this.knhList1.filter((i) => {
            return i.label == e.value
          })
          if (tmpList.length) tmpList[0].isShow = false
          tmpList2 = this.knhList2.filter((i) => {
            return i.label == e.value
          })
          if (tmpList2.length) tmpList2[0].isShow = false
          tmpList4 = this.knhList4.filter((i) => {
            return i.label == e.value
          })
          if (tmpList4.length) tmpList4[0].isShow = false
        } else {
          tmpList = this.knhList1.filter((i) => {
            return i.label == e.value
          })
          if (tmpList.length) tmpList[0].isShow = true
          tmpList2 = this.knhList2.filter((i) => {
            return i.label == e.value
          })
          if (tmpList2.length) tmpList2[0].isShow = true
          tmpList4 = this.knhList4.filter((i) => {
            return i.label == e.value
          })
          if (tmpList4.length) tmpList4[0].isShow = true
        }
      })
      if (this.twoDimensional) {
        localStorage.setItem('jx_Ktitle2', this.selectHeaderList.toString())
      } else {
        localStorage.setItem('jx_Ktitle1', this.selectHeaderList.toString())
      }
    },
    dataLen(a, b) {
      this.pagesNum = Math.ceil(this.dataLen / this.limit)
    },
    limit(a, b) {
      this.pagesNum = Math.ceil(this.dataLen / this.limit)
    },
    dataLenLeft(a, b) {
      this.pagesNumLeft = Math.ceil(this.dataLenLeft / this.limitLeft)
    },
    limitLeft(a, b) {
      this.pagesNumLeft = Math.ceil(this.dataLenLeft / this.limitLeft)
    },
    printVendor(a, b) {
      if (!a) return
      getClient({ no: a }).then((res) => {
        // console.log(res)
        this.principal = res.data.data[0].principal || res.data.data[0].name
        this.contact = res.data.data[0].contact || res.data.data[0].name
        this.cellphone = res.data.data[0].phone || ''
        this.phone = res.data.data[0].cellphone || ''
        this.address = res.data.data[0].address || ''
      })
    },
    customerNo(a, b) {
      this.customerNo = a.toUpperCase().trim()
      this.currentPageLeft = 1
    },
    inputSequence1(a, b) {
      this.inputSequence1 = a.toUpperCase().trim()
      this.currentPageLeft = 1
    },
    receiptsNumber(a, b) {
      this.receiptsNumber = a.toUpperCase().trim()
      this.currentPageLeft = 1
    },
    kindsNumber(a, b) {
      this.kindsNumber = a.toUpperCase().trim()
      this.currentPageLeft = 1
    },
    headOfficeNumber(a, b) {
      this.headOfficeNumber = a.toUpperCase().trim()
      this.currentPageLeft = 1
    },
    dateList(a, b) {
      this.currentPageLeft = 1
    }
  },
  methods: {
    changeConditions(d) {
      // console.log(d)
      this.kindsNumber = ''
      if (d.length) {
        d.forEach((e) => {
          if (!this.kindsNumber) {
            this.kindsNumber = e.styleNumber
          } else {
            this.kindsNumber += ',' + e.styleNumber
          }
        })
      }
    },
    // 补单
    supplement() {
      if (this.showpwd || this.showExport || this.showScreen) return
      if (!this.inputSequence) {
        this.$alert('请先选择一条数据再进行补单操作', '', {
          confirmButtonText: '确定'
        })
        return
      }
      // let min = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes()
      // let sec = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds()
      // console.log(this.strRandom + min + sec) //随机字符串加时间      不重复随机字符串
      // this.Str = this.strRandom + min + sec
      this.operationType = 1
      this.showpwd = true
    },
    // 改单
    revision() {
      if (this.showSupOrder || this.showExport || this.showScreen) return
      if (!this.inputSequence) {
        this.$alert('请先选择一条数据再进行改单操作', '', {
          confirmButtonText: '确定'
        })
        return
      }
      let min =
        new Date().getMinutes() < 10
          ? '0' + new Date().getMinutes()
          : new Date().getMinutes()
      let sec =
        new Date().getSeconds() < 10
          ? '0' + new Date().getSeconds()
          : new Date().getSeconds()
      console.log(this.strRandom + min + sec) //随机字符串加时间      不重复随机字符串
      this.Str = this.strRandom + min + sec
      this.operationType = 2
      this.showpwd = true
    },
    // 筛选款号
    screenStyleNumber() {
      if (this.showpwd || this.showExport || this.showSupOrder) return
      this.showScreen = true
    },
    // 导出
    Export() {
      if (this.showpwd || this.showSupOrder || this.showScreen) return
      this.showExport = true
    },
    // 确认导出
    exportConfirm() {
      this.showExport = false
      let column
      switch (this.exportType) {
        case '1':
          // 导出汇总表
          column = [
            { key: 'sellSequence', title: '客销序号', type: 'text' },
            { key: 'sellTime', title: '销货日期', type: 'text' },
            { key: 'enteringTime', title: '录入时间', type: 'text' },
            { key: 'customerStr', title: '客户', type: 'text' },
            { key: 'number', title: '数量', type: 'text' },
            { key: 'tagPrice', title: '吊牌金额', type: 'text' },
            { key: 'discount', title: '折数', type: 'text' },
            { key: 'money', title: '金额', type: 'text' },
            { key: 'operator', title: '操作员', type: 'text' },
            { key: 'affirm', title: '确认', type: 'text' },
            { key: 'checks', title: '审核', type: 'text' },
            { key: 'remark', title: '备注', type: 'text' }
          ]
          table2excel(column, this.sequenceDataList, '客户销货汇总表.xls')
          break
        case '2':
          // 导出明细表
          if (this.adjustPrice) {
            column = [
              { key: 'sequence', title: '客销序号', type: 'text' },
              { key: 'no', title: '客户编号', type: 'text' },
              { key: 'kindsNumber', title: '货号', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'fileSellingPrice', title: '建档售价', type: 'text' },
              { key: 'sum', title: '数量', type: 'text' }
            ]
            table2excel(column, this.adjustPriceList, '客户销货调整过售价.xls')
            return
          }
          if (this.twoDimensional) {
            // 二维表
            column = [
              { key: 'typeNumber', title: '款号', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'colorName', title: '颜色', type: 'text' },
              { key: 'c05', title: '05-XS', type: 'text' },
              { key: 'c07', title: '07-S', type: 'text' },
              { key: 'c09', title: '09-M', type: 'text' },
              { key: 'c11', title: '11-L', type: 'text' },
              { key: 'c13', title: '13-XL', type: 'text' },
              { key: 'c15', title: '15-2L', type: 'text' },
              { key: 'c17', title: '17-3L', type: 'text' },
              { key: 'c19', title: '19-4L', type: 'text' },
              { key: 'c21', title: '21-5L', type: 'text' },
              { key: 'c23', title: '23-6L', type: 'text' },
              { key: 'f', title: 'F', type: 'text' },
              { key: 'total', title: '小计', type: 'text' },
              { key: 'money', title: '金额', type: 'text' },
              { key: 'tagPrice', title: '吊牌金额', type: 'text' }
            ]
            if (!this.jxShowCost) {
              column = column.concat([
                { key: 'manufacturerPrice', title: '厂价', type: 'text' },
                {
                  key: 'manufacturerPriceMoney',
                  title: '厂价金额',
                  type: 'text'
                },
                { key: 'profit', title: '利润', type: 'text' }
              ])
            }
            column = newCloumn(column, this.selectHeaderList)
            table2excel(column, this.styleNumberList, '客户销货明细表2.xls')
          } else {
            column = [
              { key: 'sequence', title: '客销序号', type: 'text' },
              { key: 'business', title: '业务', type: 'text' },
              { key: 'name', title: '客户', type: 'text' },
              { key: 'kindsNumber', title: '货号', type: 'text' },
              { key: 'styleNumber', title: '款号', type: 'text' },
              { key: 'colorNo', title: '颜色编号', type: 'text' },
              { key: 'colorName', title: '颜色名称', type: 'text' },
              { key: 'size', title: '尺码', type: 'text' },
              { key: 'commodityName', title: '品名', type: 'text' },
              { key: 'sellingPrice', title: '售价', type: 'text' },
              { key: 'discount', title: '折数', type: 'text' },
              { key: 'onePrice', title: '单价', type: 'text' },
              { key: 'sum', title: '数量', type: 'text' },
              { key: 'tagPrice', title: '吊牌金额', type: 'text' },
              { key: 'money', title: '金额', type: 'text' },
              { key: 'time', title: '客销日期', type: 'text' },
              { key: 'remark', title: '备注', type: 'text' },
              { key: 'brandedName', title: '品牌', type: 'text' },
              { key: 'entryTime', title: '录入时间', type: 'text' }
            ]
            column.splice(15, 0, {
              key: 'manufacturerPrice',
              title: '厂价',
              type: 'text'
            })
            column.splice(16, 0, {
              key: 'manufacturerPriceMoney',
              title: '厂价金额',
              type: 'text'
            })
            column.splice(17, 0, {
              key: 'profit',
              title: '利润',
              type: 'text'
            })
            column = newCloumn(column, this.selectHeaderList)
            if (this.inputSequence) {
              table2excel(column, this.selectList, '客户销货明细表1.xls')
            } else {
              table2excel(column, this.kindsNumberList, '客户销货明细表1.xls')
            }
          }
      }
    },
    // 列印
    printConfirm() {
      // console.log('点击确定了')
      if (!this.styleNumberList.length) {
        this.$message.info('请勾选二维表')
        return
      }
      this.clearPrintTable()
      this.styleList = []
      this.printTotal = 0
      this.printMoney = 0
      this.printStyle = 0
      this.printSellingPrice = 0
      this.openPrint()
    },
    openPrint(x = 1, id = 'printTable') {
      let index = --x
      let printTable = document.getElementById(id)

      let length = this.styleNumberList.length

      for (index; index < length; index++) {
        const e = this.styleNumberList[index]
        // console.log(index)
        // console.log(index+1)
        this.printTotal += Number(e.total)
        this.printMoney += Number(e.money)
        this.printSellingPrice += Number(e.tagPrice)

        let row = printTable.insertRow(printTable.FetchRowCount)
        row.insertCell(0).innerHTML = index + 1
        row.insertCell(1).innerHTML = e.typeNumber + '-' + e.colorNo
        row.insertCell(2).innerHTML = e.colorName
        row.insertCell(3).innerHTML = e.commodityName
        row.insertCell(4).innerHTML = e.c05
        row.insertCell(5).innerHTML = e.c07
        row.insertCell(6).innerHTML = e.c09
        row.insertCell(7).innerHTML = e.c11
        row.insertCell(8).innerHTML = e.c13
        row.insertCell(9).innerHTML = e.c15
        row.insertCell(10).innerHTML = e.c17
        row.insertCell(11).innerHTML = e.c19
        row.insertCell(12).innerHTML = e.c21
        row.insertCell(13).innerHTML = e.c23
        row.insertCell(14).innerHTML = e.f
        row.insertCell(15).innerHTML = e.total
        row.insertCell(16).innerHTML = e.onePrice
        row.insertCell(17).innerHTML = e.money

        // console.log(parseInt((index+1)/33))
        // console.log((index+1)%33 == 0)
        if (
          parseInt((index + 1) / 33) &&
          (index + 1) % 33 == 0 &&
          index + 1 != length
        ) {
          // console.log('33倍数')
          let pageIndex = index + 3 - parseInt(index / 33) * 33
          // console.log(pageIndex)
          // console.log(index+1)    // 33
          // console.log(length)     // 36
          let startingPoint = index - 32
          let pageTotal = 0
          let pageMoney = 0
          for (let j = startingPoint; j <= index; j++) {
            pageTotal += Number(this.styleNumberList[j].total)
            pageMoney += Number(this.styleNumberList[j].money)
          }

          let rowEnd = printTable.insertRow(printTable.FetchRowCount)
          rowEnd.insertCell(0).innerHTML = '本页小计：'
          printTable.rows[pageIndex].cells[0].colSpan = '2'
          rowEnd.insertCell(1).innerHTML = pageTotal
          printTable.rows[pageIndex].cells[1].colSpan = '2'
          rowEnd.insertCell(2).innerHTML = '汇总金额：'
          printTable.rows[pageIndex].cells[2].colSpan = '4'
          rowEnd.insertCell(3).innerHTML = pageMoney.toFixed(2)
          printTable.rows[pageIndex].cells[3].colSpan = '10'

          let newHead = document.createElement('div')
          newHead.classList.add('addPrintHead')
          newHead.innerHTML = `
            <p class="rightTag" style="top: ${
              ((index + 1) / 33) * 29.7 + 3
            }cm;">白联仓库 红联财务 黄联客户</p>
            <span class="printHead">
              ${this.companyName}${this.jxQuarter}客户销货单
            </span>
            <div class="info" style="height: 25px;">
              <p style="margin: 5px 0;">客户：${this.printVendorName}</p>
              <p style="margin: 5px 0;">联系人：${this.contact}</p>
              <p style="margin: 5px 0;">销货序号：${this.inputSequence}</p>
            </div>
            <div class="info" style="height: 25px;">
              <p style="margin: 5px 0;">客户电话：${this.phone}</p>
              <p style="margin: 5px 0;">出货类型：${this.shipType}</p>
              <p style="margin: 5px 0;">销货日期：${this.inputDate}</p>
            </div>
          `
          newHead.style.pageBreakBefore = 'always'
          this.insertAfter(newHead, printTable)

          let tableId = `printTable${(index + 1) / 33}`
          // console.log(tableId)
          let tableDom = document.createElement('table')
          tableDom.border = '1'
          tableDom.align = 'center'
          tableDom.id = tableId
          tableDom.innerHTML = `
            <thead>
              <tr>
                <td style="width: 4%;padding: 0;text-align: center;" rowspan="2">序号</td>
                <td style="width: 15%;padding: 0;text-align: center;" rowspan="2">型色</td>
                <td style="width: 8%;padding: 0;text-align: center;" rowspan="2">颜色</td>
                <td style="width: 15%;padding: 0;text-align: center;" rowspan="2">品名</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">05</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">07</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">09</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">11</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">13</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">15</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">17</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">19</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">21</td>
                <td style="width: 3.8%;padding: 0;text-align: center;" nowrap="nowrap">23</td>
                <td style="width: 3.8%;padding: 0;text-align: center;">F</td>
                <td rowspan="2" style="text-align: center;width: 5%;">数量</td>
                <td rowspan="2" style="text-align: center;width: 5%;">单价</td>
                <td rowspan="2" style="text-align: center;">金额</td>
              </tr>
              <tr>
                <td style="text-align: center;border-top: 1px dotted;border-left: 1px dotted;">XS</td>
                <td style="text-align: center;border-top: 1px dotted;">S</td>
                <td style="text-align: center;border-top: 1px dotted;">M</td>
                <td style="text-align: center;border-top: 1px dotted;">L</td>
                <td style="text-align: center;border-top: 1px dotted;">XL</td>
                <td style="text-align: center;border-top: 1px dotted;">2L</td>
                <td style="text-align: center;border-top: 1px dotted;">3L</td>
                <td style="text-align: center;border-top: 1px dotted;">4L</td>
                <td style="text-align: center;border-top: 1px dotted;">5L</td>
                <td style="text-align: center;border-top: 1px dotted;">6L</td>
                <td style="text-align: center;border-top: 1px dotted;"></td>
              </tr>
            </thead>
          `
          // console.log(tableDom)
          // console.log(index)
          this.printStyleCount(e.typeNumber)
          this.insertAfter(tableDom, newHead)
          this.openPrint(index + 2, tableId)
          return
        }
        if (index + 1 == length) {
          let pageIndex = index + 3 - parseInt(index / 33) * 33
          // console.log('最后一行')
          let startingPoint = index < 33 ? 0 : parseInt(index / 33) * 33
          let pageTotal = 0
          let pageMoney = 0
          for (let j = startingPoint; j <= index; j++) {
            pageTotal += Number(this.styleNumberList[j].total)
            pageMoney += Number(this.styleNumberList[j].money)
          }
          let rowEnd = printTable.insertRow(printTable.FetchRowCount)
          rowEnd.insertCell(0).innerHTML = '本页小计：'
          printTable.rows[pageIndex].cells[0].colSpan = '2'
          rowEnd.insertCell(1).innerHTML = pageTotal
          printTable.rows[pageIndex].cells[1].colSpan = '2'
          rowEnd.insertCell(2).innerHTML = '汇总金额：'
          printTable.rows[pageIndex].cells[2].colSpan = '4'
          rowEnd.insertCell(3).innerHTML = pageMoney.toFixed(2)
          printTable.rows[pageIndex].cells[3].colSpan = '10'
        }

        this.printStyleCount(e.typeNumber)
      }

      this.printStyle = this.styleList.length
      // console.log(this.styleList)
      let int = setInterval(() => {
        if (this.printStyle) {
          clearInterval(int)
          let printHtml = document.getElementById('p').innerHTML
          let wind = window.open(
            '',
            'newwindow',
            'height=500, width=1000, top=100, left=100, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no'
          )
          wind.document.body.innerHTML = printHtml
          let style = document.createElement('style')
          style.type = 'text/css'
          style.innerHTML = resources.printCSS
          wind.document.head.appendChild(style)
          wind.print()
          return false
        }
      }, 500)
    },
    clearPrintTable() {
      let printTable = document.getElementById('printTable')
      let trs = printTable.getElementsByTagName('tr')
      let len = trs.length - 1
      for (let i = len; i > 1; i--) {
        printTable.deleteRow(i)
      }

      let printArea = document.getElementById('p')
      let tables = printArea.getElementsByTagName('table')
      len = tables.length
      for (let i = 1; i < len; i++) {
        tables[1].remove()
      }
      let addPrintHeads = document.getElementsByClassName('addPrintHead')
      len = addPrintHeads.length
      for (let i = 0; i < len; i++) {
        addPrintHeads[0].remove()
      }
    },
    printStyleCount(s) {
      if (!this.styleList.length) {
        this.styleList.push(s)
      } else {
        let exist = 0
        for (const i of this.styleList) {
          // console.log(i)
          if (i == s) {
            exist = 1
            break
          }
        }
        if (!exist) {
          this.styleList.push(s)
        }
      }
    },
    // insertAfter(p,header1) // 因为js没有直接追加到指定元素后面的方法 所以要自己创建一个方法
    insertAfter(newElement, targetElement) {
      // newElement是要追加的元素 targetElement 是指定元素的位置
      let parent = targetElement.parentNode // 找到指定元素的父节点
      if (parent.lastChild == targetElement) {
        // 判断指定元素的是否是节点中的最后一个位置 如果是的话就直接使用appendChild方法
        parent.appendChild(newElement, targetElement)
      } else {
        parent.insertBefore(newElement, targetElement.nextSibling)
      }
    },

    showRevision() {
      switch (this.operationType) {
        case 1:
          this.showSupOrder = true
          break
        case 2:
          this.showCReviSion = true
          break
        case 3:
          this.$router.push({
            path: '/delete_document',
            query: { type: 5, sequence: this.inputSequence }
          })
          this.$store.commit('addNav', {
            label: '客户销货删单',
            name: 'delete_document'
          })
          break
        default:
          break
      }
      this.showpwd = false
    },

    // 确认补单
    determine(o) {
      this.showSupOrder = false
      this.$router.push({
        path: '/customer/client_sales_mn',
        query: { oid: o }
      })
      this.$store.commit('minusNav', '客户销货')
      // this.$store.commit('addNav',{label:'客户销货',name:'client_sales_mn',path:`/customer/client_sales_mn?oid=${o}`})
    },

    // 查询
    search(st = 0) {
      if (st) {
        this.currentPageLeft = 1
        this.$refs.paginationLeft.internalCurrentPage = 1
      }

      this.inputSequence = ''
      this.adjustPrice = false
      this.dailySettlement = false

      this.sequenceDataList = []
      this.amount = 0
      this.sequenceData = []

      this.conditionList = []
      this.kindsNumberList = []
      this.dataLen = 0
      this.kindsNumberData = []

      let affirmInt
      // 查询条件是否是默认（0:是1：否， 默认只有开始时间和结束时间为查询条件）
      let defaultInquiry = 1
      let kindsNumberStr = ''

      switch (this.affirm) {
        case '全部':
          affirmInt = ''
          break
        case '已完成':
          affirmInt = 1
          break
        case '未确认':
          affirmInt = 0
          break
      }

      if (
        !this.customerNo &&
        !this.inputSequence1 &&
        !this.receiptsNumber &&
        !this.quarter &&
        !this.brandedName &&
        !this.commodityName &&
        !this.headOfficeNumber &&
        !this.business &&
        !this.area
      ) {
        defaultInquiry = 0
      }
      let params = {
        twoInfo: this.twoDimensional ? 1 : 0,
        customerNo: this.customerNo,
        startTime: this.dateList ? this.dateList[0] + ' 00:00:00' : '',
        endTime: this.dateList ? this.dateList[1] + ' 23:59:59' : '',
        // inputStartTime: this.inputDateList ? this.inputDateList[0] + ' 00:00:00' : '',
        // inputEndTime: this.inputDateList ? this.inputDateList[1] + ' 23:59:59' : '',
        business: this.business,
        sellSequence: this.inputSequence1,
        receiptsNumber: this.receiptsNumber,
        quarter: this.quarter,
        kindsNumber: this.kindsNumber,
        brandedName: this.brandedName,
        commodityName: this.commodityName,
        affirm: affirmInt,
        cooperateWay: this.cooperateWay == '全部' ? '' : this.cooperateWay,
        headOfficeNumber: this.headOfficeNumber,
        area: this.area,
        defaultInquiry,
        limit: this.limitLeft,
        page: this.currentPageLeft
      }
      // console.log(params)
      getSellInquire(params).then((res) => {
        this.currentPage = 1
        this.$refs.paginationRight.internalCurrentPage = 1

        if (res.data.code == 200) {
          this.sequenceDataList = res.data.data.sellInquireTotalList || []
          this.sequenceDataList.sort((a, b) => {
            return b.sellSequence.localeCompare(a.sellSequence)
          })
          this.amount = res.data.total
          this.dataLenLeft = res.data.total
          this.sequenceData = this.sequenceDataList

          this.conditionList = res.data.data.sellInquireInfoList || []
          this.kindsNumberList = res.data.data.sellInquireInfoList || []
          this.styleNumberList = res.data.data.totalTwoList || []
          this.detailTwo = res.data.data.customerSellInfoTwos || []

          this.sequenceDataList.forEach((e) => {
            e.customerStr = e.no + '.' + e.name
          })

          this.kindsNumberList.forEach((e) => {
            e.tagPrice = (e.sellingPrice * e.sum).toFixed(2)
            // e.manufacturerPriceMoney = (e.manufacturerPrice * e.total).toFixed(2)
            // e.profit = (e.money - e.manufacturerPriceMoney).toFixed(2)
            // e.time = e.purchaseTime.slice(0,10)
            if (!e.remark) e.remark = ''
            if (!e.manufacturerPrice) e.manufacturerPrice = ''
            if (!e.manufacturerPriceMoney) e.manufacturerPriceMoney = ''
          })

          this.summation.sum = res.data.data.sumNumberAndMoney.number
          this.summation.money = res.data.data.sumNumberAndMoney.money
          this.summation.tagPrice = res.data.data.sumNumberAndMoney.sellingPrice
          this.summation.manufacturerPriceMoney =
            res.data.data.sumNumberAndMoney.manufacturerPriceMoney
          this.summation.profit = res.data.data.sumNumberAndMoney.profit

          if (this.twoDimensional) {
            // 计算总数
            this.summation.c05 = 0
            this.summation.c07 = 0
            this.summation.c09 = 0
            this.summation.c11 = 0
            this.summation.c13 = 0
            this.summation.c15 = 0
            this.summation.c17 = 0
            this.summation.c19 = 0
            this.summation.c21 = 0
            this.summation.c23 = 0
            this.summation.f = 0

            this.styleNumberList.forEach((e) => {
              e.total =
                Number(e.c05) +
                Number(e.c07) +
                Number(e.c09) +
                Number(e.c11) +
                Number(e.c13) +
                Number(e.c15) +
                Number(e.c17) +
                Number(e.c19) +
                Number(e.c21) +
                Number(e.c23) +
                Number(e.f)
              e.tagPrice = (e.sellingPrice * e.total).toFixed(2)
              // e.manufacturerPriceMoney = (e.manufacturerPrice * e.total).toFixed(2)
              // e.profit = (e.money - e.manufacturerPriceMoney).toFixed(2)

              this.summation.c05 += Number(e.c05)
              this.summation.c07 += Number(e.c07)
              this.summation.c09 += Number(e.c09)
              this.summation.c11 += Number(e.c11)
              this.summation.c13 += Number(e.c13)
              this.summation.c15 += Number(e.c15)
              this.summation.c17 += Number(e.c17)
              this.summation.c19 += Number(e.c19)
              this.summation.c21 += Number(e.c21)
              this.summation.c23 += Number(e.c23)
              this.summation.f += Number(e.f)

              // this.summation.sum += Number(e.total)
              // this.summation.tagPrice += Number(e.tagPrice)
              // this.summation.money += Number(e.money)

              if (e.c05 === 0) e.c05 = ''
              if (e.c07 === 0) e.c07 = ''
              if (e.c09 === 0) e.c09 = ''
              if (e.c11 === 0) e.c11 = ''
              if (e.c13 === 0) e.c13 = ''
              if (e.c15 === 0) e.c15 = ''
              if (e.c17 === 0) e.c17 = ''
              if (e.c19 === 0) e.c19 = ''
              if (e.c21 === 0) e.c21 = ''
              if (e.c23 === 0) e.c23 = ''
              if (e.f === 0) e.f = ''
            })
            this.dataLen = this.styleNumberList.length
            this.kindsNumberData = this.styleNumberList.slice(0, this.limit)
          } else {
            this.dataLen = this.conditionList.length
            this.kindsNumberData = this.conditionList.slice(0, this.limit)
          }

          this.$nextTick(() => {
            this.$refs.table2.doLayout()
          })
        } else {
          this.$message('暂无数据')
        }
      })
    },

    getDaySellInfo() {
      let affirmInt
      switch (this.affirm) {
        case '全部':
          affirmInt = ''
          break
        case '已完成':
          affirmInt = 1
          break
        case '未确认':
          affirmInt = 0
          break
      }
      let params = {
        customerNo: this.customerNo,
        startTime: this.dateList ? this.dateList[0] + ' 00:00:00' : '',
        endTime: this.dateList ? this.dateList[1] + ' 23:59:59' : '',
        // inputStartTime: this.inputDateList ? this.inputDateList[0] + ' 00:00:00' : '',
        // inputEndTime: this.inputDateList ? this.inputDateList[1] + ' 23:59:59' : '',
        business: this.business,
        sellSequence: this.inputSequence1,
        receiptsNumber: this.receiptsNumber,
        quarter: this.quarter,
        kindsNumber: this.kindsNumber,
        brandedName: this.brandedName,
        commodityName: this.commodityName,
        affirm: affirmInt,
        cooperateWay: this.cooperateWay == '全部' ? '' : this.cooperateWay,
        headOfficeNumber: this.headOfficeNumber,
        area: this.area,
        defaultInquiry: 1,
        limit: this.limitLeft,
        page: this.currentPageLeft
      }
      daySellInfo(params).then((res) => {
        // console.log(res)
        if (res.data.data.totalVOMap && res.data.data.totalVOMap.length) {
          this.sequenceDataList = res.data.data.totalVOMap || []
          this.sequenceDataList.sort((a, b) => {
            return b.sellTime.localeCompare(a.sellTime)
          })
          this.amount = res.data.total
          this.dataLenLeft = res.data.total
          this.sequenceData = this.sequenceDataList

          this.sequenceDataList.forEach((e) => {
            e.customerStr = e.no + '.' + e.name
          })

          const first = this.sequenceDataList[0]
          this.dailyMap = res.data.data.infoMap || {}
          this.totalByDay = this.dailyMap[first.sellTime + '-' + first.no]
          // console.log(this.totalByDay)
          this.totalByDay.forEach((e) => {
            e.no = e.customerNo
            e.name = e.customerName
            e.customerStr = e.no + '.' + e.name
            e.sequence = e.sellSequence
            e.entryTime = e.enteringTime
            e.sum = e.number
            e.time = e.enteringTime.slice(0, 10)
          })
          this.kindsNumberData = this.totalByDay.slice(0, this.limit)
          this.dataLen = this.totalByDay.length
        }
      })
    },

    // 确认 这里是要修改请求参数的
    confirm() {
      if (!this.inputSequence) {
        this.$alert('请先选择一条数据再进行确定操作', '', {
          confirmButtonText: '确定'
        })
        return
      }
      this.sequenceRow.customerNo = this.sequenceRow.no
      this.sequenceRow.sequence = this.sequenceRow.sellSequence
      let d = {
        customerDTO: this.sequenceRow,
        validList: this.selectList
      }
      affirmSell(JSON.stringify(d)).then((res) => {
        if (res.data.code == 200) {
          for (const i of this.sequenceData) {
            if (i.sellSequence == this.inputSequence) {
              i.affirm = 1
              break
            }
          }
          this.$message({
            message: '确认成功',
            type: 'success'
          })
          this.isConfirm = true
        } else {
          this.$message.error('确认失败')
        }
      })
    },

    // 审核
    audit() {
      if (!this.inputSequence) {
        this.$alert('请先选择一条数据再进行确定操作', '', {
          confirmButtonText: '确定'
        })
        return
      }
      checkYse(JSON.stringify([this.inputSequence])).then((res) => {
        if (res.data.code == 200) {
          for (const i of this.sequenceData) {
            if (i.sellSequence == this.inputSequence) {
              i.checks = 1
              break
            }
          }
          this.$message({
            message: '审核成功',
            type: 'success'
          })
          this.isAudit = true
        } else {
          this.$message.error('审核失败')
        }
      })
    },

    // 反审
    umpire() {
      if (!this.inputSequence) {
        this.$alert('请先选择一条数据再进行确定操作', '', {
          confirmButtonText: '确定'
        })
        return
      }
      checkNo(JSON.stringify([this.inputSequence])).then((res) => {
        if (res.data.code == 200) {
          for (const i of this.sequenceData) {
            if (i.sellSequence == this.inputSequence) {
              i.checks = 0
              break
            }
          }
          this.$message({
            message: '反审成功',
            type: 'success'
          })
          this.isAudit = false
        } else {
          this.$message.error('反审失败')
        }
      })
    },

    dele() {
      if (!this.inputSequence) return
      this.operationType = 3
      this.showpwd = true
    },

    // 客户编号失去焦点
    customerNoBlur() {
      if (this.customerNo) {
        for (const i of this.customerList) {
          if (this.customerNo == i.value) {
            this.customerName = i.label
            return
          }
        }
        this.$alert('无此客户编号', '', {
          confirmButtonText: '确定'
        })
        this.customerNo = ''
        this.customerName = ''
      } else {
        this.customerName = ''
      }
    },

    rowClick(row) {
      // console.log(row)
      this.currentPage = 1
      this.$refs.table2.setCurrentRow({})
      this.detailRow = {}

      if (this.dailySettlement) {
        this.totalByDay = this.dailyMap[row.sellTime + '-' + row.no]
        this.totalByDay.forEach((e) => {
          e.no = e.customerNo
          e.name = e.customerName
          e.customerStr = e.no + '.' + e.name
          e.sequence = e.sellSequence
          e.entryTime = e.enteringTime
          e.sum = e.number
          e.time = e.enteringTime.slice(0, 10)
        })
        this.kindsNumberData = this.totalByDay.slice(0, this.limit)
        this.dataLen = this.totalByDay.length
        return
      }

      this.dataLen = this.kindsNumberList.length

      this.sequenceRow = row

      this.inputSequence = row.sellSequence
      this.printVendor = row.no
      this.printVendorName = row.no + '_' + row.name
      this.inputDate = row.sellTime.slice(0, 10)
      this.shipType = row.cooperateWay
      this.printRemark = row.remark

      // this.customerNo = row.no
      // this.customerNoBlur()

      // 确认了没
      if (row.affirm) {
        this.isConfirm = true
      } else {
        this.isConfirm = false
      }

      // 审核了没
      if (row.checks) {
        this.isAudit = true
      } else {
        this.isAudit = false
      }

      if (this.dailySettlement) {
        this.kindsNumberList.forEach((e) => {
          if (
            row.sellTime.slice(0, 10) == e.sellTime.slice(0, 10) &&
            row.no == e.no
          ) {
            this.selectList.push(e)
          }
        })
        this.dataLen = this.selectList.length
        this.kindsNumberData = this.selectList.slice(0, this.limit)
        return
      }

      this.styleNumberList = []
      this.summation.sum = row.number
      this.summation.tagPrice = row.tagPrice
      this.summation.money = row.money

      this.summation.c05 = 0
      this.summation.c07 = 0
      this.summation.c09 = 0
      this.summation.c11 = 0
      this.summation.c13 = 0
      this.summation.c15 = 0
      this.summation.c17 = 0
      this.summation.c19 = 0
      this.summation.c21 = 0
      this.summation.c23 = 0
      this.summation.f = 0

      this.selectList = []
      if (this.twoDimensional) {
        this.detailTwo.forEach((e) => {
          if (this.inputSequence == e.sellSequence) {
            e.total =
              Number(e.c05) +
              Number(e.c07) +
              Number(e.c09) +
              Number(e.c11) +
              Number(e.c13) +
              Number(e.c15) +
              Number(e.c17) +
              Number(e.c19) +
              Number(e.c21) +
              Number(e.c23) +
              Number(e.f)
            e.tagPrice = (e.sellingPrice * e.total).toFixed(2)

            this.summation.c05 += Number(e.c05)
            this.summation.c07 += Number(e.c07)
            this.summation.c09 += Number(e.c09)
            this.summation.c11 += Number(e.c11)
            this.summation.c13 += Number(e.c13)
            this.summation.c15 += Number(e.c15)
            this.summation.c17 += Number(e.c17)
            this.summation.c19 += Number(e.c19)
            this.summation.c21 += Number(e.c21)
            this.summation.c23 += Number(e.c23)
            this.summation.f += Number(e.f)

            if (e.c05 === 0) e.c05 = ''
            if (e.c07 === 0) e.c07 = ''
            if (e.c09 === 0) e.c09 = ''
            if (e.c11 === 0) e.c11 = ''
            if (e.c13 === 0) e.c13 = ''
            if (e.c15 === 0) e.c15 = ''
            if (e.c17 === 0) e.c17 = ''
            if (e.c19 === 0) e.c19 = ''
            if (e.c21 === 0) e.c21 = ''
            if (e.c23 === 0) e.c23 = ''
            if (e.f === 0) e.f = ''

            this.styleNumberList.push(e)
          }
        })
        // console.log(this.styleNumberList)
        this.dataLen = this.styleNumberList.length
        this.kindsNumberData = this.styleNumberList.slice(0, this.limit)
      } else {
        this.kindsNumberList.forEach((e) => {
          if (this.inputSequence == e.sequence) {
            this.selectList.push(e)
          }
        })
        this.dataLen = this.selectList.length
        this.kindsNumberData = this.selectList.slice(0, this.limit)
      }

      this.$nextTick(() => {
        this.$refs.table2.doLayout()
      })
    },
    detailClick(row) {
      if (this.twoDimensional || this.dailySettlement) return
      this.$refs.table1.setCurrentRow({})
      this.detailRow = row

      this.inputSequence = row.sequence

      // 确认了没
      if (row.affirm) {
        this.isConfirm = true
      } else {
        this.isConfirm = false
      }
    },

    checkImg(row) {
      let imgBox = document.getElementById('imgBox')
      imgBox.style.left = '400px'
      imgBox.style.top = '150px'

      // console.log(row)
      getKindsNumberList({ kindsNumberStr: row.typeNumber }).then((res) => {
        if (res.data.data && res.data.data.data[0]) {
          if (res.data.data.data[0].image) {
            this.imgSrc = res.data.data.data[0].image
          } else {
            this.$message('暂无图片')
          }
          this.showImg = this.imgSrc ? true : false
        }
      })
    },

    // 每页显示页数改变
    handleSizeChange(val) {
      this.limit = val
      this.currentPage = 1

      if (this.adjustPrice) {
        this.kindsNumberData = this.adjustPriceList.slice(
          0,
          this.currentPage * this.limit
        )
        return
      }
      if (this.dailySettlement) {
        this.kindsNumberData = this.totalByDay.slice(
          (this.currentPage - 1) * this.limit,
          this.currentPage * this.limit
        )
        return
      }
      if (this.twoDimensional) {
        this.dataLen = this.styleNumberList.length
        this.kindsNumberData = this.styleNumberList.slice(
          0,
          this.currentPage * this.limit
        )
      } else {
        if (this.inputSequence) {
          this.dataLen = this.selectList.length
          this.kindsNumberData = this.selectList.slice(
            0,
            this.currentPage * this.limit
          )
        } else {
          this.dataLen = this.kindsNumberList.length
          this.kindsNumberData = this.conditionList.slice(
            0,
            this.currentPage * this.limit
          )
        }
      }
    },
    // 当前页改变
    handleCurrentChange(val) {
      this.currentPage = val
      if (this.adjustPrice) {
        this.kindsNumberData = this.adjustPriceList.slice(
          (this.currentPage - 1) * this.limit,
          this.currentPage * this.limit
        )
        return
      }
      if (this.dailySettlement) {
        this.kindsNumberData = this.totalByDay.slice(
          (this.currentPage - 1) * this.limit,
          this.currentPage * this.limit
        )
        return
      }
      if (this.twoDimensional) {
        this.kindsNumberData = this.styleNumberList.slice(
          (this.currentPage - 1) * this.limit,
          this.currentPage * this.limit
        )
      } else {
        if (this.inputSequence) {
          this.kindsNumberData = this.selectList.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
        } else {
          this.kindsNumberData = this.conditionList.slice(
            (this.currentPage - 1) * this.limit,
            this.currentPage * this.limit
          )
        }
      }
    },

    handleSizeChangeLeft(val) {
      this.limitLeft = val
      if (this.dailySettlement) {
        this.getDaySellInfo()
        // this.sequenceData = this.totalByDay.slice((this.currentPageLeft-1)*this.limitLeft,this.currentPageLeft*this.limitLeft)
      } else {
        this.search(1)
        // this.sequenceData = this.sequenceDataList.slice((this.currentPageLeft-1)*this.limitLeft,this.currentPageLeft*this.limitLeft)
      }
    },
    handleCurrentChangeLeft(val) {
      this.currentPageLeft = val
      // return
      if (this.dailySettlement) {
        this.getDaySellInfo()
        // this.sequenceData = this.totalByDay.slice((this.currentPageLeft-1)*this.limitLeft,this.currentPageLeft*this.limitLeft)
      } else {
        this.search()
        // this.sequenceData = this.sequenceDataList.slice((this.currentPageLeft-1)*this.limitLeft,this.currentPageLeft*this.limitLeft)
      }
    },

    getSummaries(param) {
      const { columns, data } = param
      const sums = []
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计'
          return
        }
        const prop = column.property
        switch (prop) {
          case 'sum':
            sums[index] = this.summation.sum || ''
            break
          case 'total':
            sums[index] = this.summation.sum || ''
            break
          case 'tagPrice':
            sums[index] = this.summation.tagPrice || ''
            break
          case 'money':
            sums[index] = this.summation.money || ''
            break

          case 'manufacturerPriceMoney':
            sums[index] = this.summation.manufacturerPriceMoney || ''
            break
          case 'profit':
            sums[index] = this.summation.profit || ''
            break

          case 'c05':
            sums[index] = this.summation.c05 || ''
            break
          case 'c07':
            sums[index] = this.summation.c07 || ''
            break
          case 'c09':
            sums[index] = this.summation.c09 || ''
            break
          case 'c11':
            sums[index] = this.summation.c11 || ''
            break
          case 'c13':
            sums[index] = this.summation.c13 || ''
            break
          case 'c15':
            sums[index] = this.summation.c15 || ''
            break
          case 'c17':
            sums[index] = this.summation.c17 || ''
            break
          case 'c19':
            sums[index] = this.summation.c19 || ''
            break
          case 'c21':
            sums[index] = this.summation.c21 || ''
            break
          case 'c23':
            sums[index] = this.summation.c23 || ''
            break
          case 'f':
            sums[index] = this.summation.f || ''
            break
          case 'manufacturerPriceMoney':
            sums[index] = this.summation.manufacturerPriceMoney || ''
            break
        }
        let decimal = sums[index] ? sums[index].toString().split('.')[1] : ''
        if (decimal && decimal.length > 2) {
          sums[index] = sums[index].toFixed(2)
        }
      })
      return sums
    },

    dividerClick() {
      let content1 = document.getElementById('content1')
      let content2 = document.getElementById('content2')
      if (this.areaFlag) {
        content1.style.width = '30%'
        content2.style.width = '69%'
      } else {
        content1.style.width = '60%'
        content2.style.width = '39%'
      }
      this.areaFlag = !this.areaFlag
    },

    changeCellStyle({ row, column, rowIndex, columnIndex }) {
      let style = 'height:26px;padding:0;'
      if (!row.affirm) {
        // return style + `background-color:${this.$store.state.unconfirmedBG};`
      } else {
        // return style
      }
      return style
    }
  },
  created() {
    this.inpList = this.getInput()
    // 默认选之前一周
    // this.dateList = [this.searchDate(7),this.searchDate()]
    this.areaList = provincea

    this.knhList = this.knhList1

    if (localStorage.getItem('jx_Ktitle1')) {
      this.selectHeaderList = localStorage.getItem('jx_Ktitle1').split(',')
    }

    if (!this.jxShowCost) {
      this.knhList2 = this.knhList2.concat([
        { prop: 'manufacturerPrice', label: '厂价', width: '90', isShow: true },
        {
          prop: 'manufacturerPriceMoney',
          label: '厂价金额',
          width: '90',
          isShow: true
        },
        { prop: 'profit', label: '利润', width: '90', isShow: true }
      ])
      this.knhList1.splice(15, 0, {
        prop: 'manufacturerPrice',
        label: '厂价',
        width: '90',
        isShow: true
      })
      this.knhList1.splice(16, 0, {
        prop: 'manufacturerPriceMoney',
        label: '厂价金额',
        width: '90',
        isShow: true
      })
      this.knhList1.splice(17, 0, {
        prop: 'profit',
        label: '利润',
        width: '90',
        isShow: true
      })
    }

    // 获取所有客户信息
    this.customerList = []
    getClient({ limit: 99999 }).then((res) => {
      if (res.data.code == 200) {
        let list = res.data.data
        list.forEach((e) => {
          if (e.stop != 1) {
            this.customerList.push({ value: e.no, label: e.name })
          }
        })
        if (this.jxAgent) {
          for (const i of this.customerList) {
            if (i.label == this.operator) {
              this.customerNo = i.value
              this.customerName = i.value
              break
            }
          }
        }
      }
    })
    // 获取业务
    getClerk({ limit: 99999 }).then((res) => {
      let list = res.data.data
      list.forEach((element) => {
        if (element.department == '业务') {
          this.businessList.push({ label: element.name, value: element.name })
        }
      })
    })
    // 获取品名信息
    getProductName({ limit: 99999 }).then((res) => {
      if (res.data.code == 200) {
        let list = res.data.data
        list.forEach((e) => {
          this.commodityNameList.push({ value: e.name, label: e.name })
        })
      }
    })
    // 获取品牌
    getBranded({ limit: 99999 }).then((res) => {
      res.data.data.forEach((e) => {
        this.brandList.push({ value: e.name, label: e.name })
      })
    })

    // 获取季度
    getQuarter({ limit: 99999 }).then((res) => {
      if (res.data.code == 200) {
        res.data.data.forEach((e) => {
          this.quarterList.push({ value: e.name, label: e.name })
        })
      }
    })

    getSystemConfig({ limit: 99999 }).then((res) => {
      if (res.data.data) {
        this.companyName = res.data.data.companyName
        this.companyPhone = res.data.data.phone
      }
    })
  },
  mounted() {
    imgBox.onmousedown = function (event) {
      let imgBox = document.getElementById('imgBox')
      let rex = event.clientX - imgBox.offsetLeft
      let rey = event.clientY - imgBox.offsetTop
      document.onmousemove = (e) => {
        let xX = 0
        let yY = 0
        xX = e.clientX
        yY = e.clientY
        imgBox.style.left = xX - rex + 'px'
        imgBox.style.top = yY - rey + 'px'
      }
    }
    document.onmouseup = () => {
      document.onmousemove = null
    }
  }
}
</script>
